// 1. 和 .1 都是 true
var isNumber = function (s) {
  s = s.trim();
  if (s == null || !s.length) return false;
  let isNum = false,
    isDot = false,
    iseE = false;

  for (let i = 0; i < s.length; i++) {
    if (/\d/.test(s[i]) && s[i] >= 0 && s[i] <= 9) {
      isNum = true;
    } else if (s[i] === ".") {
      if (isDot || iseE) return false;
      isDot = true;
    } else if (s[i] == "e" || s[i] == "E") {
      if (!isNum || iseE) return false;
      iseE = true;
      isNum = false;
    } else if (s[i] === "-" || s[i] === "+") {
      if (i !== 0 && s[i - 1] !== "e" && s[i - 1] !== "E") {
        return false;
      }
    } else {
      return false;
    }
  }

  return isNum;
};
